import {Image, View} from "@tarojs/components"
import {useEffect, useState} from "react";
import Taro from "@tarojs/taro";
import styles from "./product_detail.module.scss";

const productDetail = () => {
  const [productInfo, setProductInfo] = useState<any>({});

  useEffect(() => {
    if (Taro.getCurrentInstance().router?.params) {
      const parmas: any = Taro.getCurrentInstance().router?.params
      let data = JSON.parse(decodeURIComponent(parmas.data));
      setProductInfo(data)
    }
  }, []);

  return (
    <View className="container">
      <Image className={styles.header_image} src={productInfo.imagePath}/>
      <View className={styles.detail_card}>
        <View className="text-large" style={{color: "red"}}>￥{productInfo.price}</View>
        <View>商品描述</View>
        <View className="text-small color-third-text">{productInfo.detail}</View>
      </View>
    </View>
  )
};
export default productDetail;
